package com.ui.basic.command;

import java.util.Collection;
import java.util.List;

import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;
import org.springmodules.validation.bean.conf.loader.annotation.handler.NotBlank;

import com.common.basic.base.BaseCommand;
import com.common.basic.util.Globals;
import com.ui.basic.ibatis.model.system.TblSMenu;
import com.ui.basic.ibatis.model.system.TblSRole;
import com.ui.basic.ibatis.model.system.TblSRoleMenusKey;

public class CommandRole extends BaseCommand implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4476215884022906725L;

	private String srtADD = Globals.ACTION_ADD;

	private Long id;

	@Length(max = 20)
	@NotBlank
	private String roleName;

	@NotBlank
	@Length(max = 250)
	private String roleDesc;

	private Integer roleOrder;

	private Long[] roleMenu;

	private Collection<TblSMenu> menuCollection;

	public String getSrtADD() {
		return srtADD;
	}

	public void setSrtADD(String srtADD) {
		this.srtADD = srtADD;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	public String getRoleDesc() {
		return roleDesc;
	}

	public void setRoleDesc(String roleDesc) {
		this.roleDesc = roleDesc;
	}

	public Integer getRoleOrder() {
		return roleOrder;
	}

	public void setRoleOrder(Integer roleOrder) {
		this.roleOrder = roleOrder;
	}

	public Long[] getRoleMenu() {
		return roleMenu;
	}

	public void setRoleMenu(Long[] roleMenu) {
		this.roleMenu = roleMenu;
	}

	public void setProperty(TblSRole role) {
		this.id = role.getId();
		this.roleName = role.getRoleName();
		this.roleDesc = role.getRoleDesc();
		this.roleOrder = role.getRoleOrder();
	}

	public void setMenuCollection(Collection<TblSMenu> menuCollection) {
		this.menuCollection = menuCollection;
	}

	public Collection<TblSMenu> getMenuCollection() {
		return menuCollection;
	}

	public void setPropertyRM(List<TblSRoleMenusKey> listRoleMenu) {
		if (listRoleMenu != null) {
			Long[] tempRM = new Long[listRoleMenu.size()];
			for (int i = 0; i < listRoleMenu.size(); i++) {
				TblSRoleMenusKey tbMRoleMenu = listRoleMenu.get(i);
				tempRM[i] = tbMRoleMenu.getMenuId();
			}
			setRoleMenu(tempRM);
		}
	}
}